package com.funtl.screw.admin.controller;

import cn.hutool.core.util.RandomUtil;
import com.funtl.screw.admin.service.MobileService;
import com.funtl.screw.common.core.util.ResponseResult;
import com.funtl.screw.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Lusifer
 * @since 2018/11/14
 * <p>
 * 手机验证码
 */
@RestController
@AllArgsConstructor
@RequestMapping("/mobile")
@Api(value = "mobile", tags = "手机管理模块")
public class MobileController {

    private final MobileService mobileService;

    @ApiOperation(value = "发送手机验证码", notes = "发送手机验证码")
    @Inner(value = false)
    @GetMapping("/{mobile}")
    public ResponseResult<Boolean> sendSmsCode(@PathVariable String mobile) {
        return mobileService.sendSmsCode(mobile);
    }

    @ApiOperation(value = "测试id生成", notes = "测试id生成")
    @Inner(value = false)
    @GetMapping("/testId")
    public ResponseResult<String> testId() {
        return ResponseResult.ok(RandomUtil.randomString(6));
    }
}
